home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / cad / drafix quickcad / PRO400 / MACROS / SAVESYM.D < prev    next >
Encoding:
Text File  |  1996-01-15  |  2.6 KB  |  84 lines

  1. // SaveSym.d
  2. // Saves symbols from a drawing into a designated symbol library
  3. // Select New Library from the list of symbol libraries if you wish to create a new library from the symbols
  4. //     in the drawing.
  5.  
  6.  
  7.  
  8. HANDLE    hChan;        // handle to symbol list
  9. HANDLE    hChanlib;        // handle to the symbol library directory
  10. HANDLE    hDlg;        // handle for dialog box
  11. MSGID    Ok;            // return code from dialog box
  12. STRING    sSymbol;        // symbol name
  13. STRING    sSymlib;        // library name
  14. STRING    sMessage;    // list of symbol libraries
  15. STRING    sLibname;    // name of library returned from dialog box
  16. STRING    sNewlib;        // name of new symbol library
  17. STRING    sPath;        // current SLB directory
  18. NUMBER    nSymbol;
  19. NUMBER    nCount;
  20. XY    xySymList;
  21.  
  22. Display("message", "error", "If the current drawing doesn't have symbols this won't work!");
  23.  
  24. GetData("PathSymbol", &sPath);
  25. Print("the path for symbols is : ", sPath,"\n");
  26.  
  27. hChanlib = Open("directory", sPath+"\\*.slb", "normal");
  28. if (hChanlib)
  29. {
  30.     while(GetNextFile(hChanlib, &sSymlib))
  31.     {
  32.         Print("Existing Symbol Library names are: ", sSymlib, "\n");
  33.         sMessage= sMessage + sSymlib + "\n";
  34.     }
  35.     Close("directory", hChanlib);
  36.  
  37. }
  38.  
  39. sMessage=sMessage+"NEW LIBRARY\n";
  40. Print(sMessage, "\n");
  41. // create a dialog box for selecting a symbol library
  42. hDlg = Open("dialog", "Select the desired Symbol Library to use!", "font Arial 10", 20, 20, 194, 40);
  43. AddControl(hDlg, "defaultbuttion", 140, 2, 50, 14, "OK", "%ok", "");
  44. AddControl(hDlg, "pushbutton", 140, 20, 50, 14, "Cancel", "%cancel", "");
  45. AddControl(hDlg, "rtext", 8, 18, 40, 8, "Symbol Libraries:", "", "");
  46. AddControl(hDlg, "dropdownlistbox", 52, 18, 80, 86, sMessage, "string", "sLibname" );
  47.  
  48. // displays dialog box.
  49. Ok=Display("dialog", hDlg, "%center");
  50. Close("dialog", hDlg);
  51. if (Ok!=%ok)
  52.     Exit(%cancel, "Aborting Macro as requested!");
  53.  
  54. Display("message", "error", "The existing symbol library you have selected is: " + sLibname);
  55.  
  56. if (StringCompare("NEW LIBRARY",sLibname))
  57. {
  58.     if (GetUser("string", "Please Type in the name of the desired new symbol library!", &sNewlib) != %ok)
  59.     Exit(%cancel, "Aborting Macro as requested!");
  60.     if (SetSymbolLibrary(sNewlib)!=%true)
  61.     Exit(%cancel, "Aborting Macro as requested!");
  62.  
  63. }
  64. else
  65. SetSymbolLibrary(sLibname);
  66.  
  67.  
  68.  
  69. // Adds the symbols in the current or active drawing to the designated symbol library
  70. nSymbol = 0;
  71.  
  72. //open up symbol list
  73. hChan = Open("symlist", "*");
  74. if (hChan)
  75. {
  76.     // get symbol name one at a time
  77.     while (GetNextSymbol(hChan, &sSymbol))
  78.     {
  79.         nSymbol = nSymbol+1;
  80.         Export("symbol", sSymbol);
  81.         
  82.     }
  83.     Close("symlist", hChan);
  84. }